﻿using TheBlog.NhibernateModel.Entities;

namespace TheBlog.NhibernateModel.Mappings
{
    public class UserMap : EntityMap<User>
    {
        public UserMap()
        {
            Map(x => x.UserName).Not.Nullable().Unique();
            Map(x => x.Password).Not.Nullable();
            HasMany(x => x.UserAffects)
                .KeyColumn("AffectingUserId").ForeignKeyConstraintName("FK_User_UserAffect_AffectingUserId")
                .AsBag().Cascade.AllDeleteOrphan();
        }
    }
}